import Vue from 'vue';
import VueRouter from 'vue-router';
const Login = () => import('@/components/login');
const Home = () => import('@/components/footer-home');
const HomePage = () => import('@/components/homepage/homepage');
const Questions = () => import('@/components/questions/questions');
const Video = () => import('@/components/mv/video');
const Users = () => import('@/components/users');
const Search = () => import('@/components/search/search');
const Article=()=> import('@/components/article/article')
const UserProfile=()=> import('@/components/user-profile/user-profile')
Vue.use(VueRouter);

const routes = [{
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/search',
    component: Search
  },
  {
    path: '/articles/:artId',
    component: Article,
    props: true
  },
  {
    path: '/home',
    component: Home,
    redirect: '/homepage',
    children: [{
        path: '/homepage',
        component: HomePage
      },
      {
        path: '/questions',
        component: Questions
      },
      {
        path: '/video',
        component: Video
      },
      {
        path: '/users',
        component: Users
      },
      {
        path: '/users/profile',
        component: UserProfile
      },

    ]
  }
]
/*  方法二  */
// const routes = [
//   {
//     path: '/',
//     component: () => import(/*  */'@/views/layout.vue'),
//     children: [
//       {
//         path: '/',
//         component: () => import(/*  */'@/views/home/index.vue')
//       },
//       {
//         path: '/qa',
//         component: () => import(/*  */'@/views/qa/index.vue')
//       },
//       {
//         path: '/video',
//         component: () => import(/*  */'@/views/video/index.vue')
//       },
//       {
//         path: '/my',
//         component: () => import(/*  */'@/views/my/index.vue')
//       }
//     ]
//   },
//   { path: '/login', component: () => import(/*  */'@/views/login/index.vue') },
// ]   

const router = new VueRouter({
  routes
})

export default router
